﻿using Md.Api.Model;
using Md.Api.Model.Manage.MdNavigation.Request;
using Md.Api.Service.Manage.MdNavigation;
using Microsoft.AspNetCore.Mvc;

namespace Md.Api.Controllers.Manage;
/// <summary>
/// 网站导航
/// </summary>
[ApiController]
[Produces("application/json")]
[Route("md-api/manage/md/navigation")]
public class MdNavigationController : ControllerBase
{
    /// <summary>
    /// 通过编号删除网站导航服务
    /// </summary>
    public DeleteMdNavigationByIdService deleteMdNavigationByIdService { get; set; }
    /// <summary>
    /// 通过编号删除网站导航
    /// </summary>
    /// <param name="ids">导航编号多个逗号分割（1,2,3...）</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpDelete("{ids}")]
    public async Task<ResponseMessageModel> DeleteMdNavigationById(string ids, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestDeleteMdNavigationByIdModel();

        model.Ids = ids;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => deleteMdNavigationByIdService.Execute(model));
    }

    /// <summary>
    /// 添加网站导航服务
    /// </summary>
    public InsertMdNavigationService insertMdNavigationService { get; set; }
    /// <summary>
    /// 添加网站导航
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPost]
    public async Task<ResponseMessageModel> InsertMdNavigation([FromBody] RequestInsertMdNavigationModel model)
    {
        return await Task.Run(() => insertMdNavigationService.Execute(model));
    }

    /// <summary>
    /// 通过编号更新网站导航服务
    /// </summary>
    public UpdateMdNavigationByIdService updateMdNavigationByIdService { get; set; }
    /// <summary>
    /// 通过编号更新网站导航
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpPut]
    public async Task<ResponseMessageModel> UpdateMdNavigationById([FromBody] RequestUpdateMdNavigationByIdModel model)
    {
        return await Task.Run(() => updateMdNavigationByIdService.Execute(model));
    }

    /// <summary>
    /// 通过编号获取网站导航服务
    /// </summary>
    public GetMdNavigationByIdService getMdNavigationByIdService { get; set; }
    /// <summary>
    /// 通过编号获取网站导航
    /// </summary>
    /// <param name="id">导航编号</param>
    /// <param name="signModel">加密实体</param>
    /// <returns>ResponseMessageModel</returns>
    [HttpGet("{id}")]
    public async Task<ResponseMessageModel> GetMdNavigationById(long id, [FromQuery] RequestSignModel signModel)
    {
        var model = new RequestGetMdNavigationByIdModel();

        model.NavigationId = id;
        model.TimesTamp = signModel.TimesTamp;
        model.Mac = signModel.Mac;
        model.Ip = signModel.Ip;
        model.Sign = signModel.Sign;
        model.Version = signModel.Version;
        model.Token = signModel.Token;

        return await Task.Run(() => getMdNavigationByIdService.Execute(model));
    }

    /// <summary>
    /// 获取网站导航列表服务
    /// </summary>
    public GetMdNavigationListService getMdNavigationListService { get; set; }
    /// <summary>
    /// 获取网站导航列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("list"), HttpPost]
    public async Task<ResponseMessageModel> GetMdNavigationList([FromBody] RequestGetMdNavigationListModel model)
    {
        return await Task.Run(() => getMdNavigationListService.Execute(model));
    }

    /// <summary>
    /// 分页获取网站导航列表服务
    /// </summary>
    public GetMdNavigationPageListService getMdNavigationPageListService { get; set; }
    /// <summary>
    /// 分页获取网站导航列表
    /// </summary>
    /// <param name="model">请求实体</param>
    /// <returns>ResponseMessageModel</returns>
    [Route("listPage"), HttpPost]
    public async Task<ResponseMessageModel> GetMdNavigationPageList([FromBody] RequestGetMdNavigationPageListModel model)
    {
        return await Task.Run(() => getMdNavigationPageListService.Execute(model));
    }
}

